﻿// AAControlDlg.cpp: 实现文件
//

#include "pch.h"
#include "ProjectAA.h"
#include "AAControlDlg.h"
#include "afxdialogex.h"


// CAAControlDlg 对话框

IMPLEMENT_DYNAMIC(CAAControlDlg, CDialogEx)

CAAControlDlg::CAAControlDlg(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_DIALOG_AA, pParent)
	, m_nCapWaitTime(0)
	, m_dFieldSfrDiffSpec(0)
	, m_dCurrentLimit(0)
{

}

CAAControlDlg::~CAAControlDlg()
{
}

void CAAControlDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT_CAP_WAIT, m_nCapWaitTime);
	DDX_Text(pDX, IDC_EDIT_FIELD_SFRDIFF, m_dFieldSfrDiffSpec);
	DDX_Text(pDX, IDC_EDIT_STEP_WAIT2, m_dCurrentLimit);
}


BEGIN_MESSAGE_MAP(CAAControlDlg, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON_SAVE, &CAAControlDlg::OnBnClickedButtonSave)
END_MESSAGE_MAP()


// CAAControlDlg 消息处理程序


BOOL CAAControlDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	ReadConfigIni();

	return TRUE;  // return TRUE unless you set the focus to a control
				  // 异常: OCX 属性页应返回 FALSE
}

void CAAControlDlg::ReadConfigIni()
{
	//m_nCapWaitTime = gSystemMgr.m_nCaptureWaitTime;
	//m_dFieldSfrDiffSpec = gSystemMgr.m_dFieldSfrDiffSpec;
	//m_dCurrentLimit = gSystemMgr.m_dCurrentLimit;

	UpdateData(FALSE);
}

void CAAControlDlg::SaveValueToConfig()
{
	//UpdateData(TRUE);
	//CString cstr;
	//gSystemMgr.m_nCaptureWaitTime = m_nCapWaitTime;
	//cstr.Format(L"%d", gSystemMgr.m_nCaptureWaitTime);
	//gSystemMgr.m_cAAConfigIni.SaveConfigIni(L"AA", L"m_nCaptureWaitTime", cstr);

	//gSystemMgr.m_dFieldSfrDiffSpec = m_dFieldSfrDiffSpec;
	//cstr.Format(L"%.4f", gSystemMgr.m_dFieldSfrDiffSpec);
	//gSystemMgr.m_cAAConfigIni.SaveConfigIni(L"AA", L"m_dFieldSfrDiffSpec", cstr);

	//gSystemMgr.m_dCurrentLimit = m_dCurrentLimit;
	//cstr.Format(L"%.3f", gSystemMgr.m_dCurrentLimit);
	//gSystemMgr.m_cAAConfigIni.SaveConfigIni(L"AA", L"m_dCurrentLimit", cstr);

	gSystemLog.DisplayLogAndSave(L"AA保存数据完成", LV_EVENT);
}

void CAAControlDlg::OnCancel()
{
	// TODO: 在此添加专用代码和/或调用基类

	CDialogEx::OnCancel();
}


void CAAControlDlg::OnBnClickedButtonSave()
{
	SaveValueToConfig();
}
